import Vue from 'vue'
import VueRouter from 'vue-router'
import store from '../store'
import HomeView from '../views/HomeView.vue'
import MeView from '../views/MeView.vue'
import Login from '@/components/Login.vue'
import shouye from '@/views/shouye.vue'
import ProduceList from '@/views/ProduceList.vue'
import MyOrder from '@/views/MyOrder.vue'
import smrz from '@/views/smrz.vue'
import yinsi from '@/views/yinsi.vue'
import quanxian from '@/views/quanxian.vue'
import PettyCash from '../views/PettyCash.vue'
import kefu from '../views/kefu.vue'
import repayment from '../views/RePayment.vue'
import yanqi from "../views/yanqi.vue";
import privacypoicy from '../views/PrivacyPolicy.vue'
import smrzform from '../views/smrzform.vue'
import startpage from '../views/startpage.vue'
import sencoed from '../views/sencoed.vue'
import kefuform from "../views/form/kefuform.vue";
import workInfo from '../views/form/workInfo.vue'
import huoti from '../views/form/huoti.vue'
import { formToJSON } from 'axios'
import Terms from '../views/Terms.vue'

Vue.use(VueRouter)

const routes = [{
    path: '/',
    component: startpage
}, {
    path: '/shouye',
    component: shouye,
    children: [{
        path: '/',
        component: HomeView
    }, {
        path: '/me',
        name: 'me',
        component: MeView
    }]
}, {
    path: '/workInfo',
    component: workInfo
},
{
    path: '/produce',
    component: ProduceList,
}, {
    path: '/myorder',
    name: 'myorder',
    component: MyOrder,
}, {
    path: '/smrz',
    component: smrz,
    keepAlive: true,
    meta: { keepAlive: true },
}, {
    path: '/login',
    component: Login
}, {
    path: '/quanxian',
    component: quanxian
}, {
    path: '/pettycash',
    component: PettyCash
}, {
    path: '/kefu',
    component: kefu
}, {
    path: '/repayment',
    component: repayment
}, {
    path: '/yanqi',
    component: yanqi
}, {
    path: '/privacypoicy',
    component: privacypoicy
}, {
    path: '/smrzform',
    component: smrzform
}, {
    path: '/sencoed',
    component: sencoed
}, {
    path: '/kefuform',
    component: kefuform
}, {
    path: '/huoti',
    component: huoti
}, {
    path: '/Terms',
    component: Terms
}
]

const router = new VueRouter({
    mode: 'hash',
    base: process.env.BASE_URL,
    routes
})
//路由前置守卫
router.afterEach((to, from) => {
    console.log(to, from)
    if (to.fullPath === '/shouye') {
        store.commit('shouye/doChange', 1)
    }
})
export default router